
************************************************************************************************
* RD figs. subgroup to "Public Health Policy At Scale.."
************************************************************************************************

clear 
set more off 
set matsize 8000 
cap log close 

cd "D:\Data\workdata\707116\SIDS_RDD\"

use "SIDS_analysis_final_full.dta", clear

log using "Revision1/log_files/03 RDfigs sub days.log", replace


g dc_sids_oth = dc_sids + dc_all_other 


g 		mor1_exc_sids = mor1 - dc_sids_oth
replace mor1_exc_sids =0 if mor1==0 


g 		mor5_exc_sids = mor5 - dc_sids_oth
replace mor5_exc_sids =0 if mor5==0 


g m_high_ed = m_short + m_mid + m_long
egen dc_other_non_sids = rowmax(dc_inf  dc_neo dc_nerv dc_resp)

g  preterm = . 
replace  preterm = 1 if fullterm37==0
replace  preterm = 0 if fullterm37==1

global motherset "mage m_basic m_voc m_high m_partn m_couple  m_immigrant" 
global childset "female border birthweight LBW gage_wks fullterm37"
global outset1 "dc_sids dc_sids_oth mor1 mor5"
global outset2 "dc_pre_nat dc_cog_mal mor1_exc_sids mor5_exc_sids" 


g   male = . 
replace male = 0 if female==1
replace male = 1 if female==0

g firstchild = . 
replace firstchild = 0 if border>1 
replace firstchild = 1 if border==1


global resset1 "LBW preterm"  
global resset2 "firstchild  m_voc m_high"	
global resset3 "male"
global resset4 "m_basic"
global resset5 "m_immigrant"

	
global bin "1" 
graph set window fontface "Georgia"


do "Revision1/days/rdprogs_cols1_v02.do"



tempfile t1 
save `t1'

foreach x in $resset1{
use `t1', clear 
keep if `x'==1
rdintgraphtlim mor1 dif  $bin  "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0(200)1200," 
graph export "Revision1/output/days/sub_`x'.png", replace width(1650) height(1200) 
}


foreach x in $resset2{
use `t1', clear 
keep if `x'==1
rdintgraphtlim mor1 dif  $bin  "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0(30)120," 
graph export "Revision1/output/days/sub_`x'.png", replace width(1650) height(1200) 
}


foreach x in $resset3{
use `t1', clear 
keep if `x'==1
rdintgraphtlim mor1 dif  $bin  "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0(30)150," 
graph export "Revision1/output/days/sub_`x'.png", replace width(1650) height(1200) 
}


foreach x in $resset4{
use `t1', clear 
keep if `x'==1
rdintgraphtlim mor1 dif  $bin  "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0(30)180," 
graph export "Revision1/output/days/sub_`x'.png", replace width(1650) height(1200) 
}


foreach x in $resset5{
use `t1', clear 
keep if `x'==1
rdintgraphtlim mor1 dif  $bin  "" "Born after Dec 1991 (in months), size(5) color(black)"  ///
" " "0(30)210," 
graph export "Revision1/output/days/sub_`x'.png", replace width(1650) height(1200) 
}


log close 

 





